package create.builder;

/**
 * @author dali
 * @date 2021-07-09 18:00
 * @Description 流行的建造者模式
 */

public class House {
    //地基
    private String base;
    //墙
    private String wall;
    //吊顶
    private String cell;

    public House(Builder builder) {
        this.base = builder.base;
        this.wall = builder.wall;
        this.cell = builder.cell;
    }

    public static class Builder{
        //地基
        private String base;
        //墙
        private String wall;
        //吊顶
        private String cell;
        //set
        public Builder base(String base) {
            this.base = base;
            return this;
        }
        public Builder wall(String wall) {
            this.wall = wall;
            return this;
        }
        public Builder cell(String cell) {
            this.cell = cell;
            return this;
        }
        public House build(){
            return new House(this);
        }
    }

    @Override
    public String toString() {
        return "House{" +
                "base='" + base + '\'' +
                ", wall='" + wall + '\'' +
                ", cell='" + cell + '\'' +
                '}';
    }
}
